Problem: Every card in a deck has a picture of one shape - circle, square, or triangle, which is painted in one of the three colors - red, blue, or green. Furthermore, each color is applied in one of three shades - light, medium, or dark. The deck has 27 cards, with every shape-color-shade combination represented. A set of three cards from the deck is called complementary if all of the following statements are true:
i. Either each of the three cards has a different shape or all three of the card have the same shape.
ii. Either each of the three cards has a different color or all three of the cards have the same color.
iii. Either each of the three cards has a different shade or all three of the cards have the same shade.
How many different complementary three-card sets are there?

Solution: Case 1: All three attributes are the same. This is impossible since sets contain distinct cards.
Case 2: Two of the three attributes are the same. There are ${3\choose 2}$ ways to pick the two attributes in question. Then there are $3$ ways to pick the value of the first attribute, $3$ ways to pick the value of the second attribute, and $1$ way to arrange the positions of the third attribute, giving us ${3\choose 2} \cdot 3 \cdot 3 = 27$ ways.
Case 3: One of the three attributes are the same. There are ${3\choose 1}$ ways to pick the one attribute in question, and then $3$ ways to pick the value of that attribute. Then there are $3!$ ways to arrange the positions of the next two attributes, giving us ${3\choose 1} \cdot 3 \cdot 3! = 54$ ways.
Case 4: None of the three attributes are the same. We fix the order of the first attribute, and then there are $3!$ ways to pick the ordering of the second attribute and $3!$ ways to pick the ordering of the third attribute. This gives us $(3!)^2 = 36$ ways.
Adding the cases up, we get $27 + 54 + 36 = \boxed{117}$.